www.gusucode.com > VC++ 宾馆管理系统(MSSQL) > VC++ 宾馆管理系统(MSSQL)/gusucode/Code/AppendAccountDLG.cpp

    //Download by http://www.NewXing.com
// AppendAccountDLG.cpp : implementation file
//

#include "stdafx.h"
#include "hotel_mis.h"
#include "AppendAccountDLG.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAppendAccountDLG dialog


CAppendAccountDLG::CAppendAccountDLG(CWnd* pParent /*=NULL*/)
	: CDialog(CAppendAccountDLG::IDD, pParent)
{
	//{{AFX_DATA_INIT(CAppendAccountDLG)
	m_sPWD1 = _T("");
	m_sPWD2 = _T("");
	m_sUSER = _T("");
	//}}AFX_DATA_INIT
}


void CAppendAccountDLG::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAppendAccountDLG)
	DDX_Text(pDX, IDD_APPEDNACCOUNT_PWD1, m_sPWD1);
	DDX_Text(pDX, IDD_APPEDNACCOUNT_PWD2, m_sPWD2);
	DDX_Text(pDX, IDD_APPEDNACCOUNT_USER, m_sUSER);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CAppendAccountDLG, CDialog)
	//{{AFX_MSG_MAP(CAppendAccountDLG)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAppendAccountDLG message handlers

void CAppendAccountDLG::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData(true);
    m_sUSER.TrimRight(" ");

	// Judge whether user name is null
	if ( ""==m_sUSER )
	{
		AfxMessageBox(_T("请输入用户名称"), MB_ICONEXCLAMATION);
        return;
	}

	// Judge whether the user exsists
	_variant_t Holder, strQuery;
    strQuery = "select * from user_Info where user_ID='"+m_sUSER+"'";
	theApp.ADOExecute(theApp.m_pADOSet, strQuery);
	int iCount = theApp.m_pADOSet->GetRecordCount();
	if ( 0!=iCount ) 
	{
		AfxMessageBox(_T("用户名已经存在,请重新输入用户名"), MB_ICONEXCLAMATION);
        return;
	}
	
	// Make sure pwd1 is not null
    if ( ""==m_sPWD1 )
	{
		AfxMessageBox(_T("密码不能未空"), MB_ICONEXCLAMATION);
        return;
	}
	
	// Judge whether pwd1==pwd2
    if ( 0!=m_sPWD1.Compare(m_sPWD2) )
	{
		AfxMessageBox(_T("两次输入密码不一样,请确认"), MB_ICONEXCLAMATION);
        return;
	}

	CDialog::OnOK();
}

BOOL CAppendAccountDLG::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	((CEdit*)GetDlgItem(IDD_APPEDNACCOUNT_USER))->SetLimitText(15);
    ((CEdit*)GetDlgItem(IDD_APPEDNACCOUNT_PWD1))->SetLimitText(10);
	((CEdit*)GetDlgItem(IDD_APPEDNACCOUNT_PWD2))->SetLimitText(10);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}